<?php defined('_JEXEC') or die('Restricted access'); ?>

<?php  JHTML::_('behavior.tooltip');  ?>

<?php

    //添加toolbar 按钮
	JToolBarHelper::title( JText::_( '系统消息管理' ), 'inbox.png' );
//	JToolBarHelper::custom( 'logout', 'cancel.png', 'cancel_f2.png', 'Logout' );
	JToolBarHelper::deleteList('你真的要删除该系统消息吗？','remove','删除');
//	JToolBarHelper::deleteList('你真的要解封该用户吗？','unban','解封用户');
//	JToolBarHelper::editListX('edit','用户设置');
	JToolBarHelper::addNewX();
//	JToolBarHelper::help( 'screen.users' );
?>

<form action="index.php?option=com_sysnotices" method="post" name="adminForm">
	<table>
		<tr>
			<td width="100%">
				<?php echo JText::_( '搜索' ); ?>:
				<input type="text" name="search" id="search" value="<?php echo $this->lists['search'];?>" class="text_area" onchange="document.adminForm.submit();" />
				<button onclick="this.form.submit();"><?php echo JText::_( 'Go' ); ?></button>
				<button onclick="document.getElementById('search').value='';this.form.getElementById('filter_type').value='0';this.form.getElementById('filter_logged').value='0';this.form.submit();"><?php echo JText::_( 'Reset' ); ?></button>
			</td>
			<td nowrap="nowrap">
				<?php echo $this->lists['type'];?>
				<?php //echo $this->lists['logged'];?>
			</td>
		</tr>
	</table>

	<table class="adminlist" cellpadding="1">
		<thead>
			<tr>
				<th width="2%" class="title">
					<?php echo JText::_( 'NUM' ); ?>
				</th>
				<th width="3%" class="title">
					<input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count($this->items); ?>);" />
				</th>
				<th width="10%" class="title" nowrap="nowrap">
					<?php echo JText::_( '序号' ); ?>
				</th>
				<th width="8%" class="title">
					<?php echo JHTML::_('grid.sort',   '接收消息用户ID', 'a.to_profile', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>
				</th>
				<th width="15%" class="title" >
					<?php echo JText::_('消息内容'); ?>
				</th>
				<th width="15%" class="title">
					<?php echo JText::_('消息内容(HTML)'); ?>
				</th>
				<th width="10%" class="title">
					<?php echo JText::_('消息类型'); ?>
				</th>
				<th width="10%" class="title">
					<?php echo JHTML::_('grid.sort',   '发送时间', 'a.created', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>
				</th>
			
				
			</tr>
		</thead>
		<tfoot>
			<tr>
				<td colspan="10">
					<?php echo $this->pagination->getListFooter(); ?>
				</td>
			</tr>
		</tfoot>
		<tbody>
		<?php
			$k = 0;
			for ($i=0, $n=count( $this->items ); $i < $n; $i++)
			{
				$row 	=& $this->items[$i];

//				$img 	= $row->is_banned ? 'tick.png' : '';
//				$task 	= $row->is_banned ? 'unban' : 'enban';
//				$alt 	= $row->is_banned ? JText::_( '解封' ) : JText::_( '封禁' );
                switch($row->message_type)
                {
                	case 0:
                		$messagetype = '0-Broadcast Message';
                		break;
                	case 1:
                		$messagetype = '1-Groupsystem Message';
                		break;
                	case 2:
                		$messagetype = '2-Marketing Message';
                		break;
                	case 4:
                		$messagetype = '4-Group Invitation';
                		break;
                		
                }
                
                $link 	= 'index.php?option=com_users&amp;view=user&amp;task=edit&amp;cid[]='. $row->to_profile. ''; 
			?>
			<tr class="<?php echo "row$k"; ?>">
				<td>
					<?php echo $i+1+$this->pagination->limitstart;?>
				</td>
				<td>
					<?php echo JHTML::_('grid.id', $i, $row->id ); ?>
				</td>
				<td>
					<?php echo $row->id; ?>
				</td>
				<td>
					<a href="<?php echo $link; ?>">
						<?php echo $row->to_profile; ?></a>
				</td>
				<td>
					<?php echo $row->content; ?>
				</td>
				<td>
					<?php echo $row->rendered; ?>
				</td>
				<td>
					<?php echo $messagetype; ?>
				</td>
				<td nowrap="nowrap">
					<?php echo $row->created; ?>
				</td>
				
			</tr>
			<?php
				$k = 1 - $k;
				}
			?>
		</tbody>
	</table>

	<input type="hidden" name="option" value="com_sysnotices" />
	<input type="hidden" name="task" value="" />
	<input type="hidden" name="boxchecked" value="0" />
	<input type="hidden" name="filter_order" value="<?php echo $this->lists['order']; ?>" />
	<input type="hidden" name="filter_order_Dir" value="<?php echo $this->lists['order_Dir']; ?>" />
	<?php echo JHTML::_( 'form.token' ); ?>
</form>